import QtQuick 2.0
import "../FKWidget/"
import "../FKWidgets/"

FKVisualInterface{
    id: vi
    signal eAddLang(var lng, var lngLbl)
    onEAddLang: langWidget.addLang(lng,lngLbl)
    signal eLang
    onELang: langWidget.show()
    signal eMainMenu
    onEMainMenu: mainMenu.show()
    signal eHideMainMenu
    onEHideMainMenu:{mainMenu.hide();net.hide()}
    signal eClientMenu
    onEClientMenu: clientMenu.show()
    signal eHideClientMenu
    onEHideClientMenu: clientMenu.hide()
    signal eUserMenu
    onEUserMenu: userMenu.show()
    signal eHideUserMenu
    onEHideUserMenu: userMenu.hide()
    signal eRoomList
    onERoomList: roomList.show()
    signal eHideRoomList
    onEHideRoomList: roomList.hide()
    signal eAppUpdateMenu
    onEAppUpdateMenu: updateWidget.show()
    signal eHideAppUpdateMenu
    onEHideAppUpdateMenu: updateWidget.hide()

    signal languageChosen(var lng)
    onLanguageChosen: mainMenu.show()
    signal localManagerRequested
    signal serverManagerRequested(var port)
    signal clientManagerRequested(var ip, var port)
    signal resetManagerRequested
    signal createUserRequested(var userName)
    signal deleteUserRequested(var userName)
    signal addUserRequested(var userName)
    signal removeUserRequested(var userName)
    signal usersApply
    signal updateRoomList
    signal createRoom(var roomType,var roomName,var description,var password)
    signal enterRoom(var roomID)
    signal chooseClient(var cName, var cPassword)
    signal genClient(var cName, var cPassword, var cValidator)

    signal download
    signal restart
    signal interruptDownloading
    signal skip

    Rectangle{
        property var topLevelWidget:null
        color:"black"
        anchors{
            top:parent.top
            left:parent.left
            bottom:parent.bottom
            right: keyboard.left
        }

        FKLanguageChoose{
            id: langWidget
            onLanguageChosen: vi.languageChosen(lng)
        }

        FKMainMenu{
            id:mainMenu
            onNetRequested: net.show()
            onLocalRequested: vi.localManagerRequested()
        }

        FKNetMenu{
            id:net
            onStartServerRequested: vi.serverManagerRequested(port)
            onJoinServerRequested: vi.clientManagerRequested(ip,port)
        }

        FKClientWidget{
            id:clientMenu
            onCancel: vi.resetManagerRequested()
            onChooseClient: vi.chooseClient(cName,cPassword)
            onGenClient: vi.genClient(cName,cPassword,cValidator)
        }

        FKUserMenu{
            id:userMenu
            onCancel: vi.resetManagerRequested()
            onCreateUser: vi.createUserRequested(userName)
            onDeleteUser: vi.deleteUserRequested(userName)
            onAddUser: vi.addUserRequested(userName)
            onRemoveUser: vi.removeUserRequested(userName)
            onApply: vi.usersApply()
        }

        FKRoomListWidget{
            id:roomList
            onCanceled: userMenu.show()
            onCreateRoomRequested: vi.createRoom(roomType,roomName,description,password)
            onEnterRoomRequested: vi.enterRoom(roomID)
            onRefreshRequested: vi.updateRoomList()
        }

        FKAppUpdateWidget{
            id:updateWidget
            onRestart: vi.restart()
            onDownload: vi.download()
            onSkip: vi.skip()
            onInterrupt: vi.interruptDownloading()
            onCancel: vi.resetManagerRequested()
        }
    }
    FKVirtualKeyboard{
        id:keyboard
        anchors{
            top:parent.top
            right:parent.right
            bottom:parent.bottom
        }
        onButtonPressed: vi.virtualKeyPressed(b,txt)
    }
}
